import service from '@/utils/request'
import { mailMessage } from './../advertising/index';

// 获取省市区
export function getRegion() {
    return service({
        url: '/xinfa-service/v1/sys-region/',
        method: 'get',
    })
}
// 查询一级地区
export function getEconomize() {
    return service({
        url: '/xinfa-service/v1/sys-region/get-economize',
        method: 'get',
    })
}
// 查询下级地区
export function getSubordinateArea(id:any) {
    return service({
        url: '/xinfa-service/v1/sys-region/get-subordinate-area?id=' + id,
        method: 'get',
    })
}
// 设备分页
export function devicePage(params: any) {
    return service({
        url: '/xinfa-service/v1/device/page',
        method: 'get',
        params
    })
}
// 获取设备所有软件版本
export function software() {
    return service({
        url: '/xinfa-service/v1/device/get/software-version',
        method: 'get'
    })
}
export function devicePages(data: { pageNum: any, keyword: any }) {
    return service({
        url: '/xinfa-service/v1/device/page?pageNum=' + data.pageNum + '&keyword=' + data.keyword,
        method: 'get'
    })
}

// 设备表详情
export function device(data: any) {
    return service({
        url: '/xinfa-service/v1/device/' + data,
        method: 'get'
    })
}

// 添加分组表
export function addGroups(data: any) {
    return service({
        url: '/xinfa-service/v1/device-group',
        method: 'post',
        data
    })
}

// 修改分组表
export function putGroups(data: any) {
    return service({
        url: '/xinfa-service/v1/device-group',
        method: 'put',
        data
    })
}

// 获取分组表
export function gainGroups() {
    return service({
        url: '/xinfa-service/v1/device-group/',
        method: 'get',
    })
}

// 删除设备组表
export function deviceGroup(data: any) {
    return service({
        url: "/xinfa-service/v1/device-group/" + data,
        method: 'delete'
    })
}

// 添加设备列表
export function addDevice(data: any) {
    return service({
        url: '/xinfa-service/v1/device',
        method: 'post',
        data
    })
}

// 设备详情
export function deviceEdit(data: any) {
    return service({
        url: '/xinfa-service/v1/device/' + data,
        method: 'get'
    })
}

// 批量修改设备分组
export function updateGroup(data: any) {
    return service({
        url: '/xinfa-service/v1/device/update-group/',
        method: 'post',
        data
    })
}

// 阿里云临时凭证
export function getCredit() {
    return service({
        url: '/xinfa-service/v1/oss/getCredit',
        method: 'get'
    })
}

// 修改设备表
export function devicePut(data: any) {
    return service({
        url: "/xinfa-service/v1/device",
        method: 'put',
        data
    })
}

// 设备开机/重启
export function devicePoweron(data: number | string) {
    return service({
        url: "/xinfa-service/v1/device/device-power-on",
        method: 'post',
        data
    })
}

// 设备关机
export function deviceShutdown(data: number | string) {
    return service({
        url: "/xinfa-service/v1/device/device-shutdown",
        method: 'post',
        data
    })
}

// 设备静音/取消静音
export function deviceControl(id: any ) {
    return service({
        url: "/xinfa-service/v1/device/device-volume-control",
        method: 'get',
        params: {id}
    })
}

// 批量静音
export function deviceMute(data: Array<string | number>) {
    return service({
        url: "/xinfa-service/v1/device/device-mute",
        method: 'post',
        data
    })
}

// /xinfa-service/v1/device/device-off-mute

// 批量取消静音
export function deviceoffMute(data: Array<string | number>) {
    return service({
        url: "/xinfa-service/v1/device/device-off-mute",
        method: 'post',
        data
    })
}

//添加目录素材表
export function sourceDirectory(data: any) {
    return service({
        url: '/xinfa-service/v1/source-directory',
        method: 'post',
        data
    })
}

//添加素材表
export function sourceMaterial(data: any) {
    return service({
        url: '/xinfa-service/v1/source-material',
        method: 'post',
        data
    })
}
//移动素材表
export function sourceMaterialPut(data: any) {
    return service({
        url: '/xinfa-service/v1/source-material/move-file',
        method: 'put',
        data
    })
}
// 修改素材表
export function sourceMaterialPutEdit(data: any) {
    return service({
        url: '/xinfa-service/v1/source-material',
        method: 'put',
        data
    })
}
// 获取素材表分页
export function sourceMaterialPage(data: { directoryId: any, pageNum: any, pageSize: any, fileType: any ,keyword:any}) {
    return service({
        url: '/xinfa-service/v1/source-material/page?directoryId=' + data.directoryId + '&pageSize=' + data.pageSize + '&keyword='+data.keyword + '&pageNum=' + data.pageNum + '&fileType=' + data.fileType,
        method: 'get'
    })
}

// 修改设备详情灯光 音量
export function deviceService(data: any) {
    return service({
        url: '/xinfa-service/v1/device-config',
        method: 'put',
        data
    })
}

// 获取设备详情灯光 音量
export function deviceConfig(data: any) {
    return service({
        url: '/xinfa-service/v1/device-config/' + data,
        method: 'get'
    })
}

// 获取素材目录表列表
export function sourcedeviceConfig() {
    return service({
        url: '/xinfa-service/v1/source-directory/',
        method: 'get'
    })
}

// 获取素材目录表列表
export function sourcedeviceDirectory() {
    return service({
        url: '/xinfa-service/v1/source-material/get-file-directory',
        method: 'get'
    })
}

// 获取素材表详情
export function sourcedeviceMaterialry(data: any) {
    return service({
        url: '/xinfa-service/v1/source-material/' + data,
        method: 'get'
    })
}

// 删除素材表
export function delect(data: any) {
    return service({
        url: '/xinfa-service/v1/source-material/' + data,
        method: 'delete'
    })
}
// 批量删除素材表
export function alldelect(data: any) {
    return service({
        url: '/xinfa-service/v1/source-material/batch-delete',
        method: 'delete',
        data
    })
}
// 添加节目分组
export function programGroup(data: any) {
    return service({
        url: '/xinfa-service/v1/program-group',
        method: 'post',
        data
    })
}

// 获取节目分组
export function programGroupGet() {
    return service({
        url: '/xinfa-service/v1/program-group/',
        method: 'get'
    })
}
// 删除节目分组
export function DelectPrograms(id:any) {
    return service({
        url: '/xinfa-service/v1/program-group/'+ id,
        method: 'delete'
    })
}
// 节目表详情
export function getScene(linkProgram:any) {
    return service({
        url: '/xinfa-service/v1/scene/?linkProgram='+linkProgram,
        method: 'get'
    })
}


// 通过ip获取城市天气信息
export function weatherIp() {
    return service({
        url: '/intfapi-service/v1/amap/weather-ip',
        method: 'get'
    })
}
// 是否存在未读消息
export function mailMessages() {
    return service({
        url: '/xinfa-service/v1/mail-message/exist-unread-message',
        method: 'post'
    })
}